import request from "@/utils/request"

/**
 * 获取文件列表数据
 * @param {*} query
 * @returns
 */
export function getSysFileList(query){
    return request({
        url:'/business/sys-files/list',
        method:'get',
        params:query
    })
}
/**
 * 单个文件id
 * @param {Long} id
 * @returns
 */
export function delFile(id){
    return request({
        url:'/business/sys-files/delete/'+id,
        method:'get'
    })
}

/**
 * 根据id查找对应的文件数据
 */
export function getFile(id){
    return request({
        url:'/business/sys-files/getFileById/'+id,
        method:'get'
    })
}

/**
 * 上传文件
 *
 */
 export function upload (parameter) {
    return request({
      url: '/business/sys-files/upload',
      method: 'post',
      data: parameter
    })
  }

/**
 * 下载文件
 * @param {Long} id
 * @returns
 */
export function download(id){
    return request({
        url:'/business/sys-files/download/'+id,
        method:'get',
        responseType: 'blob'
    })
}

/**
 * 下载文件
 * @param {Long} id
 * @returns
 */
export function downloadPLM(id){
    return request({
        url:'/business/sys-files/download/plm/'+id,
        method:'get',
        responseType: 'blob'
    })
}



/**
 * 通过配置项下载文件
 * @param {String} key
 * @returns
 */
 export function downloadByConfig(key){
    return request({
        url:'/business/sys-files/downloadByConfig/'+key,
        method:'get',
        responseType: 'blob'
    })
}

/**
 * 批量删除文件
 * @param {Array} ids 文件id数组
 * @returns
 */
export function batchDelete(ids){
    return request({
        url:'/business/sys-files/deleteBatchById',
        method:'post',
        data:JSON.stringify(ids)
    })
}
/**
 * 批量上传文件
 * @param {*} param
 * @returns
 */
export function batchUploadFiles(param){
    return request({
        url:'/business/sys-files/batchUpload',
        method:'post',
        data:param
    })
}
